<?php
namespace app\api\controller\new;

use think\Controller;
use think\Request;
use app\common\model\device\Device;
use think\Db;
use app\common\model\power\Rolepower;

class Product extends Controller
{
    public function initialize()
    {
        parent::initialize();
        $this->is_login();
        Rolepower::powerguard('305002'); // 设备管理权限
    }
    private function is_login()
    {
        $data = \app\common\model\user\User::is_sessionlogin();
        if (!$data['code']) {
            $data['options'] = 'relogin';
            json($data)->send();
            exit;
        }
    }
    // 设备列表（305002）
    public function productInfo(Request $request)
    {
        $loginUser = session('user');
        if (!$loginUser) {
            return json(['code'=>0, 'msg'=>'未登录']);
        }
        $list = Device::select();
        return json(['code'=>1, 'msg'=>'success', 'data'=>$list]);
    }
} 